﻿
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.Text;

using Swaf;
using Swaf.BizObj;
using Swaf.Gui;
using Swaf.Security;

namespace PageEditing.Gui
{
	public class MenuTypesBizProc : BaseBusinessProcess
	{
		public MenuTypesBizProc(ActiveBizProc procState) : base(procState) { }
		
		protected override void setupRuleNames()
		{
			m_getBizObjListRule = "getMenuTypes";
			m_getBizObjDetailsRule = "getMenuDetailsForEditing";
			m_updateBizObjRule ="updateMenuForEditing";
		}

		public override Privileges CurrentEditPrivilege
		{
			get { return CurrentPrincipal.getPrivilege("AppFunctions.ManageCompanyConfiguration"); }
		}

		public override IBizObj getBizObj(object keyValue)
		{
			IBizObj curMenu = m_procState.OfflineState.State.get("CurMenu") as IBizObj;
			if (curMenu != null && ((IComparable)curMenu.KeyValue).CompareTo(keyValue) == 0)
				return curMenu;
			curMenu = base.getBizObj(keyValue);
			m_procState.OfflineState.State.put("CurMenu", curMenu);
			return curMenu;
		}

		public override IResults updateBizObj(IBizObj obj)
		{
			IResults rc = base.updateBizObj(obj);
			m_procState.OfflineState.State.put("CurMenu", null);
			return rc;
		}

		static object[] s_empty = new object[0];
		protected override object[] getBizObjListRuleParameters(object parentId, IBizObj filterSort)
		{
			return s_empty;
		}
	}
}
